package com.nlx.notes.module.service.loan;

import com.nlx.notes.module.bean.bo.LoanDetailBO;
import com.nlx.notes.module.bean.dto.loan.LoanDetailQueryDTO;
import com.nlx.notes.module.bean.dto.loan.LoanSummarySaveDTO;
import com.nlx.notes.module.bean.dto.loan.LoanSummaryUpdateDTO;
import com.nlx.notes.module.bean.dto.loan.RepayDetailSaveDTO;
import com.nlx.notes.module.entity.LoanDetail;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author nlx
 * @since 2025-10-25
 */
public interface ILoanDetailService extends IService<LoanDetail> {

    /**
     * 保存借款数据
     * @param loanSummarySaveDTO 参数
     * @return Boolean
     */
    Boolean saveLoan(LoanSummarySaveDTO loanSummarySaveDTO);

    long countByCondition(LoanDetailQueryDTO loanDetailQueryDTO);

    List<LoanDetailBO> selectPageByCondition(LoanDetailQueryDTO loanDetailQueryDTO);

    boolean updateLoanDetail(LoanSummaryUpdateDTO loanSummaryUpdateDTO);

    LoanDetail findById(Long id,Long userId);

    Integer sumLoanDetail(Long summaryId, String code);

    /**
     * 还款
     * @param repayDetailSaveDTO 还款参数
     * @return boolean
     */
    LoanDetail saveRepay(RepayDetailSaveDTO repayDetailSaveDTO);

    /**
     * 删除还款详情数据
     * @param id 记录id
     * @param userId 用户id
     * @return boolean
     */
    boolean removeLoanDetail(Long id, Long userId);

    /**
     * 通过summaryId删除所有记录数据
     * @param summaryId 总计id
     * @param userId 用户id
     * @return boolean
     */
    boolean removeAllRecordBySummaryId(Long summaryId, Long userId);

    List<Long> findFlowIdsBySummaryId(Long summaryId, Long userId);
}
